<?php
echo '<script type="text/javascript">';
require APP . WEBROOT_DIR . DS . "js" . DS . "validate" . DS . "show_add.js";
echo '</script>';
?>
<div class="shows form">
<?php echo $this->Form->create('Show', array('id'=>'ShowAddForm'));?>
	<fieldset>
		<legend><?php __('Editar Show'); ?></legend>
	<?php
		echo $this->Form->input('id');
		echo $this->Form->input('name', array('label'=>'Nombre'));
		echo $this->Form->input('description', array('label'=>'Descripción', 'type'=>'textarea'));
                echo $this->Form->input('count_costumes', array('label' => 'Cantidad de Trajes', 'options' => array('Seleccione', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), 'onchange'=>'mostrar_tr(); return false;'));
        ?> 
        <table cellpadding="0" cellspacing="0">
            <tr>
                <th></th>
                <th>Traje</th>
                <th>Elegido</th>
            </tr>
            <?php
            $i = 1;
            for ($i; $i <= 10; $i++) {
                $class = null;
                if ($i % 2 == 0) {
                    $class = 'altrow';
                }
                ?>
                <tr class="<?php echo $class; ?>" id="tr_<?php echo $i; ?>">
                    <td><?php echo $i; ?>&nbsp;</td>
                    <td><?php echo $this->Form->input('costume_' . $i, array('label' => false, 'options' => $costumes)); ?></td>
                    <td><?php echo $this->Form->input('costume_check_' . $i, array('label' => false, 'type' => 'checkbox')); ?></td>
                </tr>
                <?php
            }
            ?>
        </table>
	</fieldset>
<?php echo $this->Form->end(__('Editar', true));?>
</div>
<script type="text/javascript">
    $().ready(function(){
        mostrar_tr();
    });
    
    function mostrar_tr(){
        var cant_trajes = $('#ShowCountCostumes').val();
        var i = 0;
        for(i; i <= 10; i++){
            if(i <= cant_trajes){
                //lo tengo que mostrar
                $('#tr_'+i).show();
            }else{
                //lo tengo que ocultar
                $('#tr_'+i).hide();
                //y le saco el default
                $('#ShowCostumeCheck'+i).attr('checked', false);
            }
        }
    }
</script>